package com.yulongtian.oneProblemEveryDay.month202302;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

/**
 * https://leetcode.cn/problems/shortest-path-with-alternating-colors/
 * 题解见
 * https://leetcode.cn/problems/shortest-path-with-alternating-colors/solution/java-99-jian-dan-yi-dong-bfs-by-joneli-3ybb/
 *
 * @author yulongTian
 * @create 2023-02-02 10:45
 */
public class Test02 {
    public static void main(String[] args) {
        int[][] redEdges = {{0, 1}, {1, 0}, {1, 2}};
        int[][] blueEdges = {{1, 2}, {2, 0}};
        int n = 3;
        System.out.println(Arrays.toString(shortestAlternatingPaths(n, redEdges, blueEdges)));
    }

    public static int[] shortestAlternatingPaths(int n, int[][] redEdges, int[][] blueEdges) {
        //构建红边
        HashMap<Integer, List<Integer>> red = buildGraph(redEdges);
        //构建蓝边
        HashMap<Integer, List<Integer>> blue = buildGraph(blueEdges);


        return null;
    }

    //构建图
    public static HashMap<Integer, List<Integer>> buildGraph(int[][] edges) {
        HashMap<Integer, List<Integer>> map = new HashMap<>();
        for (int[] edge : edges) {
            int x = edge[0];
            int y = edge[1];
            if (!map.containsKey(x)) {
                List<Integer> temp = new ArrayList<>();
                temp.add(y);
                map.put(x, temp);
            } else {
                map.get(x).add(y);
            }
        }
        return map;
    }

}
